package com.codingvip.dynamic;

public class CoinChange {
    int[] coin = {1, 3, 5};
    int totalCoin = 9;
    int[] maybe = new int[9];

    public static void main(String[] args) {
        CoinChange cc = new CoinChange();
        int result = cc.testCalCoin(4);
        System.out.println(result);
    }

    public int testCalCoin(int totalCoin) {
        System.out.println("totalCoin：" + totalCoin);
        if (totalCoin < 1) {
            return Integer.MAX_VALUE;
        }
        if (totalCoin == 1) {
            return 1;
        }
        if (totalCoin == 3) {
            return 1;
        }
        if (totalCoin == 5) {
            return 1;
        }
        return 1 + testCalCoin(myMinMethod(testCalCoin(totalCoin - 1), testCalCoin(totalCoin - 3), testCalCoin(totalCoin - 5)));
    }

    public int myMinMethod(int a, int b, int c) {
        int minab = (Math.min(a, b));
        int minac = (Math.min(a, c));
        return Math.min(minab, minac);

    }
}
